package com.hzz.framework.fileServer.controller;

import com.hzz.framework.annotation.NoAuthorize;
import com.hzz.framework.fileServer.baidu.ueditor.ActionEnter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@NoAuthorize
@Slf4j
@Controller
public class UEController {
    @Value("${file-server.upload}")
    String rootPath;
    @Value("${file-server.download}")
    String download;

    @Autowired
    private ActionEnter actionEnter;

    @RequestMapping(value = "/file/ue/controller")
    @ResponseBody
    public String actionEnter(HttpServletRequest request, HttpServletResponse response) throws Exception {
        log.info("UE actionEnter");

        request.setCharacterEncoding("utf-8");
        response.setHeader("Content-Type", "text/html");
        request.setAttribute("download", download);

        return actionEnter.init(request, rootPath).exec();
    }
}
